doc: bool,
dest: Option<String>,
plugin: bool,
+ harness: bool, // whether to use the test harness (--test)
}
impl Profile {
dest: None,
plugin: false,
doctest: false,
+ harness: true,
}
}
self.test
}
+ pub fn uses_test_harness(&self) -> bool {
+ self.harness
+ }
+
pub fn is_doctest(&self) -> bool {
self.doctest
}
self.plugin = plugin;
self
}
+
+ pub fn harness(mut self, harness: bool) -> Profile {
+ self.harness = harness;
+ self
+ }
}
impl<H: hash::Writer> hash::Hash<H> for Profile {
debug,
plugin,
dest: ref dest,
+ harness: harness,
// test flags are separated by file, not by profile hash, and
// env/doc also don't matter for the actual contents of the output
test: _,
doctest: _,
} = *self;
- (opt_level, debug, plugin, dest).hash(into)
+ (opt_level, debug, plugin, dest, harness).hash(into)
}
}
cmd = cmd.args(["--cfg", "ndebug"]);
}
- if profile.is_test() {
+ if profile.is_test() && profile.uses_test_harness() {
cmd = cmd.arg("--test");
}
bench: Option<bool>,
doc: Option<bool>,
plugin: Option<bool>,
+ harness: Option<bool>,
}
#[deriving(Decodable,Encodable,PartialEq,Clone)]
bench: None,
doc: None,
plugin: None,
+ harness: None,
}
}
}
let path = test.path.clone().unwrap_or_else(|| {
TomlString(default(test))
});
+ let harness = test.harness.unwrap_or(true);
// make sure this metadata is different from any same-named libs.
let mut metadata = metadata.clone();
metadata.mix(&format!("test-{}", test.name));
- let profile = &Profile::default_test();
+ let profile = &Profile::default_test().harness(harness);
dst.push(Target::test_target(test.name.as_slice(),
&path.to_path(),
profile,
let path = bench.path.clone().unwrap_or_else(|| {
TomlString(default(bench))
});
+ let harness = bench.harness.unwrap_or(true);
// make sure this metadata is different from any same-named libs.
let mut metadata = metadata.clone();
metadata.mix(&format!("bench-{}", bench.name));
- let profile = &Profile::default_bench();
+ let profile = &Profile::default_bench().harness(harness);
dst.push(Target::bench_target(bench.name.as_slice(),
&path.to_path(),
profile,
compiling = COMPILING,
dir = p.url()).as_slice()));
})
+
+test!(test_no_harness {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [[bin]]
+ name = "foo"
+ test = false
+
+ [[test]]
+ name = "bar"
+ path = "foo.rs"
+ harness = false
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("foo.rs", "fn main() {}");
+
+ assert_that(p.cargo_process("test"),
+ execs().with_status(0)
+ .with_stdout(format!("\
+{compiling} foo v0.0.1 ({dir})
+{running} target[..]bar-[..]
+",
+ compiling = COMPILING, running = RUNNING,
+ dir = p.url()).as_slice()));
+})